<?php
if(isset($_POST['arguments']))
{
	include_once("../../DataProvider.php");
	$TenGame = $_POST['arguments']["tenGame"];
    $LinkArtwork = $_POST['arguments']["linkArt"];
    $Price = $_POST['arguments']["price"];
    $type = $_POST['arguments']["cate"];
	$device = $_POST['arguments']["device"];
	$hot = $_POST['arguments']["hot"];
	$size = $_POST['arguments']["size"];
	$note = $_POST['arguments']["model"];
	
	$sql = "SELECT * FROM tbl_games WHERE GameName = '".$TenGame."'";
	$ds = DataProvider::ExecuteQuery($sql);

	if(mysql_num_rows($ds)>0)
	{ 
		echo "<script type='text/javascript'>alert('Game đã được up!');</script>";
	}
	else
	{
		
		date_default_timezone_set("Asia/Ho_Chi_Minh");
		$date =	date('Y-m-d H:i:s');
		
		$sqlin = "INSERT INTO tbl_games (Status,GameName,Price,CategoriesID,Artwork,Size,CreateDate,Notes,Device) VALUES ($hot,".'"'.$TenGame.'"'.",$Price,$type,'".$LinkArtwork."',".$size.",'$date','".$note."',$device)";
		$dsGame = DataProvider::ExecuteQueryGetID($sqlin);
		if($dsGame)
		{
		echo"<script>
			$('#msg').html('Successful!');
			
			$('#msg').fadeIn();

              $('#msg').fadeOut(3000);
			</script>";
		}
		else
		{
			echo"<script>
			alert('Error!');

              $('#msg').fadeOut(3000);
			</script>";
		}
}}
?>